package net.tycmc.cty.ctyms.timejob.iems.job;

import java.text.ParseException;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import net.tycmc.bulb.common.util.DateUtil;
import net.tycmc.bulb.common.util.StringUtil;
import net.tycmc.cty.ctyms.timejob.common.DateControl;
import net.tycmc.cty.ctyms.timejob.common.DateRegUtil;
import net.tycmc.cty.ctyms.timejob.common.DynamicReadConfig;
import net.tycmc.cty.ctyms.timejob.iems.service.FuelLevelMonitorService;

public class FuelLevelMonitorJob extends QuartzJobBean {
	private FuelLevelMonitorService flms;
	

	public FuelLevelMonitorService getFlms() {
		return flms;
	}


	public void setFlms(FuelLevelMonitorService flms) {
		this.flms = flms;
	}


	@Override
	protected void executeInternal(JobExecutionContext arg0)
			throws JobExecutionException {
		// TODO Auto-generated method stub
		System.out.println("---------------------燃油液位统计作业开始------------------------------"+DateControl.getDateTime(0));
		String bgnTime=DateUtil.addDay(-1);
		String endTime=DateUtil.addDay(-1);
		try {
			String timeString=DynamicReadConfig.getConfigProperty("config.properties","fuleMonitor");
			if(StringUtil.isValid(timeString)){
				bgnTime=timeString.split("~")[0];
				endTime=timeString.split("~")[1];
			}
			List<String>listtime=DateRegUtil.iterateTime(bgnTime,endTime);
			for(String time:listtime){
				flms.startWork(time);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("---------------------燃油液位统计作业开始结束------------------------------"+DateControl.getDateTime(0));
	}
}
